window.onload = function() {

    var submit33 = document.getElementById("submit33");
    // var name = username.value;
    // var key = password.value;
    // var ID = id.value;
    submit2.onmousedown = function() {

            ajax({

                type: 'post',
                dataType: 'json',
                url: 'http://www.rushmc.top/api/dynamicState/insert',
                data: {
                    "id": 421,
                    "userId": 1,
                    "username": "bb",
                    "content": "群除我佬",
                    "title": "过来玩玩，大佬们等等我",
                    "creationTime": "2021-04-25T22:50:39.000+00:00",
                    "hasPicture": 1,
                    // "urls": ["2.jpg", "3.jpg"]
                },
                success: function(result) {
                    // 检测接口有没有连成功
                    if (result.code == 200) {
                        submit2.innerHTML = '返回成功';
                        submit2.className = 'sb sb-success';
                        // result.data;
                        console.log('success');
                    } else {
                        console.log('error');
                    }
                }
            })
        }
        // 向服务端发送请求
    submit33.onmousedown = function() {
        ajax({

            type: 'get',
            dataType: 'json',
            url: 'http://www.rushmc.top/api/dynamicState/select/all',
            data: {

            },
            success: function(result) {
                // 检测接口有没有连成功
                if (result.code == 200) {
                    submit33.innerHTML = '返回成功';
                    submit33.className = 'sb sb-success';
                    // result.data;
                    console.log('success');
                    var demo = document.getElementById('demo');
                    // var value, value1, value2, value3, value4;
                    // let Div = document.getElementById("Id");
                    //id: 161, userId: 36, username: "hardens", content: "这个图片url集合是本地的图片路径？", title: "难啊难", 
                    for (let i = 0; i < result.data.length; i++) {

                        var div = document.createElement("div");
                        div.id = "slide";
                        // var LI = document.createElement('div');
                        // var odiv = document.createElement('div');
                        div.innerHTML = '<div class="de"><div class="zi0"><h5 class="ii">用户id: ' + result.data[i].userId + '</h5><h5 class="ii">用户名字：' + result.data[i].username + '</h5><h5 class="ii">动态id：' + result.data[i].id + '</h5></div><li class="time">发布时间：' + result.data[i].creationTime + '</li><li class="zi">' + result.data[i].title + '</li><h5 class="zi1">发布内容：' + result.data[i].content + '</h5><ul></ul></div>'
                            // `<div>${result.data[i].id}</div>
                            //  <b>${result.data[i].userId}<b>
                            //  <b>${result.data[i].username}<b>
                            //  <b>${result.data[i].content}<b>
                            //  <br>${result.data[i].title}<br>`
                            // UL.appendChild(LI);
                            // odiv.appendChild(UL);
                        demo.appendChild(div);

                    }


                } else {
                    submit33.innerHTML = '返回错误';
                    submit33.className = 'sb sb-error';

                }
            },
        })
    }
}